<template>
  <div class="form4">
    <Header_></Header_>
    <div class="form4_content">
      <el-form :model="form4Data" :rules="rules" ref="form4" label-width="80px" class="demo-ruleForm" :status-icon="statusIcon" label-position="top">
        <!--        学校名称-->
        <el-form-item label="学校名称" prop="school_name">
          <el-input v-model="form4Data.school_name"></el-input>
        </el-form-item>
        <!--        学历-->
        <el-form-item label="学历" prop="education_background" required>
          <el-input v-model="form4Data.education_background"></el-input>
        </el-form-item>
        <!--      就读时间  -->
        <Date_ :form4Data="form4Data"></Date_>
        <!--        专业名称-->
        <el-form-item label="专业名称" prop="major_name" required>
          <el-input v-model="form4Data.major_name"></el-input>
        </el-form-item>
        <!--        在校经历-->
        <el-form-item label="在校经历" prop="experience_school">
          <el-input type="textarea" v-model="form4Data.experience_school" resize="vertical"></el-input>
        </el-form-item>
        <el-form-item class="btn-container">
          <el-button @click="resetForm('form4')">重置</el-button>
          <el-button type="primary" @click="submitForm('form4')">下一步</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import Header_ from './component/Header_'
import Date_ from './component/Date_'

export default {
  name: 'index',
  components: {Date_, Header_},
  data() {
    return {
      statusIcon: true,
      // form2数据
      form4Data: {
        school_name: '',
        education_background: '',
        major_name: '',
        experience_school: '',
        start_date: '',
        end_date: ''
      },
      // 验证规则
      rules: {
        school_name: [
          {required: true, message: '请输入学校名称', trigger: 'blur'}
        ],
        education_background: [
          {required: true, message: '请输入您学历', trigger: 'blur'}
        ],
        major_name: [
          {required: true, message: '请输入专业名称', trigger: 'blur'}
        ],
        end_date: [
          {required: true, message: '请输入您的入学年月', trigger: 'blur'}
        ],
        position_name: [
          {required: true, message: '请输入您的毕业年月', trigger: 'blur'}
        ]
      }
    }
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
          console.log(this.form2Data)
          this.$router.push('/')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>

<style lang="scss" scoped>
.form4 {
  box-sizing: border-box;
  margin: 0 auto;
  width: 500px;
  overflow: auto;
  background-color: #ffffff;
  border: 1px solid #cccccc;
  border-radius: 12px;
  margin-top: 20px;

  .form4_content {
    padding: 0 20px;
  }

  .btn-container {
    display: flex;
    justify-content: flex-end;
  }
}
</style>
